﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace FoodBank.Core.Repository
{
    public interface IRepository<T> where T : class 
    {
        /// <summary>
        /// Adds the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Add(T entity);
        /// <summary>
        /// Updates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Update(T entity);
        /// <summary>
        /// Deletes the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Delete(T entity);
        /// <summary>
        /// Deletes using the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        void Delete(Expression<Func<T, bool>> predicate);
        /// <summary>
        /// Retrieves the entity usning id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        T RetrieveById(int id);
        /// <summary>
        /// Retrieves all.
        /// </summary>
        /// <returns></returns>
        IEnumerable<T> RetrieveAll();
        /// <summary>
        /// Retrieves many entities using the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        IEnumerable<T> RetrieveMany(Expression<Func<T, bool>> predicate);   
    }
}